﻿
#region Usings

using FasterWPF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Markup;
using wpfToolkit = Xceed.Wpf.Toolkit;
using System.Reactive;
using System.Reactive.Subjects;
using System.Reactive.Linq;
using System.Windows.Threading;
using FasterWPF.Selectors;
using FasterWPF.Observables;
#endregion

namespace FasterWPFDemo
{

    //public class FakeMouseDevice : MouseDevice
    //{ 
    
    //}


    public static class MenuBarService
    {
        public static Menu CreateMenuBar()
        {
            return FasterWPF.Factory
            .BeginMenuSettings(double.NaN, 20D, ContainerType.HorizontalPanel, Brushes.WhiteSmoke)
            .SetItemBorderSettings<Menu>(110D, 20D, Brushes.Silver, new Thickness(2))
            .EndMenuSettings();
        }

        public static void CreateMenuBarItems(Menu mnu, Canvas cnvs, string cnvsguid1, string cnvsguid2, string cnvsguid3)
        {
            MenuBuilder.BuildMenu(mnu, cnvs, cnvsguid1, cnvsguid2, cnvsguid3);
        }

        public static void CreateAeroMenuBarItems(Menu mnu, Canvas cnvs, string cnvsguid1, string cnvsguid2, string cnvsguid3, string cnvsguid4)
        {
            MenuBuilder.BuildAeroMenu(mnu, cnvsguid1, cnvsguid2, cnvsguid3, cnvsguid4);
        }
    }
    
    public static class MenuBuilder
    {  
        //MENU CONSTANTS
        private readonly static Brush BACKGROUND_COLOR = Brushes.WhiteSmoke;
        private readonly static Brush FOREGROUND_COLOR = Brushes.Black;
        private readonly static Brush MOUSEOVER_BACKGROUND_COLOR = Brushes.LightBlue;
        private readonly static Brush MOUSEOVER_FOREGROUND_COLOR = Brushes.Black;
        private readonly static Brush MOUSEOVER_BORDER_COLOR = Brushes.Gray;
        private readonly static string FONT_FAMILY = "Segoe UI";
        private readonly static double FONT_SIZE = 12;
        private readonly static FontWeight FONT_WEIGHT = FontWeights.Bold;

        //SUB-MENU CONSTANTS
        private readonly static Brush SUBMENU_BACKGROUND_COLOR = Brushes.WhiteSmoke;
        private readonly static Brush SUBMENU_MOUSEOVER_BACKGROUND_COLOR = Brushes.LightBlue;
        private readonly static Brush SUBMENU_MOUSEOVER_BORDER_COLOR = Brushes.Gray;
        private readonly static double SUBMENU_FONT_SIZE = 10;
        private readonly static string SUBMENU_FONT_FAMILY = "Verdana";
        private readonly static FontWeight SUBMENU_FONT_WEIGHT = FontWeights.Bold;

        //MENU ITEM 1
        const double MENU1_WIDTH = 85D;
        const double MENU1_HEIGHT = 20D;
        const double MENU1_BORDER_WIDTH = 83D;
        const double MENU1_BORDER_HEIGHT = 18D;

        //MENU ITEM 2
        const double MENU2_WIDTH = 90D;
        const double MENU2_HEIGHT = 20D;
        const double MENU2_BORDER_WIDTH = 88D;
        const double MENU2_BORDER_HEIGHT = 18D;

        //MENU ITEM 2 SUB-MENU AND SUB-MENU ITEMS
        const double SUB_MENU_WIDTH = 290D;
        const double SUB_MENU_HEIGHT = 170D;
        const double SUB_MENU_ITEM_WIDTH = 286D;
        const double SUB_MENU_ITEM_HEIGHT = 20D;
        const double SUB_MENU_ITEM_BORDER_WIDTH = 284D;
        const double SUB_MENU_ITEM_BORDER_HEIGHT = 18D;

        //MENU ITEM 3
        const double MENU3_WIDTH = 95D;
        const double MENU3_HEIGHT = 20D;
        const double MENU3_BORDER_WIDTH = 93D;
        const double MENU3_BORDER_HEIGHT = 18D;

        #region Create Top-Level Menus

        private static void createTopLevelMenu1(Menu mnu, Canvas cnvs, string cnvsguid1, string cnvsguid2, string cnvsguid3, Border subMenuBorder)
        {
            MenuItem m1 = FasterWPF.Factory
            .BeginMenuComposite(MENU1_WIDTH, MENU1_HEIGHT, "_File", mnu, MOUSEOVER_BACKGROUND_COLOR, BACKGROUND_COLOR, MOUSEOVER_FOREGROUND_COLOR, FOREGROUND_COLOR, FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
            .SetMouseOverBorderColor(MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
            .AddMenuItem(MENU1_BORDER_WIDTH, MENU1_BORDER_HEIGHT, (o, ev) =>
            {
                   //b: On click, display sub-menu
                   MenuItemExt.DisplaySubMenu(cnvs, cnvsguid1, subMenuBorder, 3D, 21D, 500);
                   MenuItemExt.HideSubMenu(cnvs, cnvsguid2);
                   MenuItemExt.HideSubMenu(cnvs, cnvsguid3);
            })
            //.AddImageToMenuItem(@"pack://siteoforigin:,,,/Images/filemenu.png", UriKind.Absolute)
            .EndMenuComposite();
        }

        private static void createTopLevelMenu2(Menu mnu, Canvas cnvs, string cnvsguid1, string cnvsguid2, string cnvsguid3, Border subMenuBorder)
        {
            //MENU ITEM 2 with Sub-Menu
            MenuItem m2 = FasterWPF.Factory
            .BeginMenuComposite(MENU2_WIDTH, MENU2_HEIGHT, "_Edit", mnu, MOUSEOVER_BACKGROUND_COLOR, BACKGROUND_COLOR, MOUSEOVER_FOREGROUND_COLOR, FOREGROUND_COLOR, FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
            .SetMouseOverBorderColor(MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
            .AddMenuItem(MENU2_BORDER_WIDTH, MENU2_BORDER_HEIGHT, (o, ev) =>
            {
                //b: On click, display sub-menu
                MenuItemExt.DisplaySubMenu(cnvs, cnvsguid2, subMenuBorder, 88D, 21D, 500);
                MenuItemExt.HideSubMenu(cnvs, cnvsguid1);
                MenuItemExt.HideSubMenu(cnvs, cnvsguid3);
            })
            .EndMenuComposite();
        }

        private static void createTopLevelMenu3(Menu mnu, Canvas cnvs, string cnvsguid1, string cnvsguid2, string cnvsguid3, Border subMenuBorder2)
        {
            MenuItem m3 = FasterWPF.Factory
            .BeginMenuComposite(MENU3_WIDTH, MENU3_HEIGHT, "_View", mnu, MOUSEOVER_BACKGROUND_COLOR, BACKGROUND_COLOR, MOUSEOVER_FOREGROUND_COLOR, FOREGROUND_COLOR, FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
            .SetMouseOverBorderColor(MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
            .AddMenuItem(MENU3_BORDER_WIDTH, MENU3_BORDER_HEIGHT, (o, ev) =>
            {
                //b: On click, display sub-menu
                MenuItemExt.DisplaySubMenu(cnvs, cnvsguid3, subMenuBorder2, 178D, 21D, 500);
                MenuItemExt.HideSubMenu(cnvs, cnvsguid1);
                MenuItemExt.HideSubMenu(cnvs, cnvsguid2);
            })
            .EndMenuComposite();
        }

        #endregion

        public static void BuildMenu(Menu mnu, Canvas cnvs, string cnvsguid1, string cnvsguid2, string cnvsguid3)
        {
            //no submenu for menu1 at this time
            Border subMenuForMenu1 = createSubMenu_forMenu1(cnvs, cnvsguid1);

            createTopLevelMenu1(mnu, cnvs, cnvsguid1, cnvsguid2, cnvsguid3, subMenuForMenu1);

            Border subMenuForMenu2 = createSubMenu_forMenu2(cnvs, cnvsguid2);

            createTopLevelMenu2(mnu, cnvs, cnvsguid1, cnvsguid2, cnvsguid3, subMenuForMenu2);

            Border subMenuForMenu3 = createSubMenu_forMenu3(cnvs, cnvsguid3);

            createTopLevelMenu3(mnu, cnvs, cnvsguid1, cnvsguid2, cnvsguid3, subMenuForMenu3);
        }
        
        #region Create Sub-Menus

        private static Border createSubMenu_forMenu1(Canvas cnvs, string cnvsguid1)
        {
            //SUB-MENU 2
            //Step 1: create a Border to hold the sub-menu and set it to hide itself on mouse-out
            Border subMenuBorder1 = new Border();
            subMenuBorder1.Initialize(120D, 27D, ContainerType.HorizontalPanel, Brushes.Gray, new Thickness(1), Brushes.WhiteSmoke);
            subMenuBorder1.BeginSettings<Border>().SetItemBorderSettings<Border>(200D, 27D, Brushes.LightGray, new Thickness(1)).EndSettings<Border>();
            subMenuBorder1.SubscribeEventOnParent<Border, MouseEventArgs>("MouseLeave",
                (eventPattern =>
                {
                    //a: On mouse out, hide sub-menu
                    MenuItemExt.HideSubMenu(cnvs, cnvsguid1);
                }));

            //Step 2: create the submenu and set its orientation to vertical
            Menu subMenu1 = FasterWPF.Factory
           .BeginMenuSettings(150D, 27D, ContainerType.HorizontalPanel, Brushes.WhiteSmoke)
           .EndMenuSettings();
            MenuItemExt.SetMenuOrientationToVertical(subMenu1);

            //Step 3: add the individual menuitems to the submenu
            MenuItem subMenu1Item1 = FasterWPF.Factory
             .BeginMenuComposite(145D, 20D, "_Exit Alt-F4", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
             .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
             .AddMenuItem(SUB_MENU_ITEM_WIDTH - 171 , SUB_MENU_ITEM_HEIGHT - 2, (o, ev) => { Application.Current.Shutdown(); })
             .EndMenuComposite();

            //Step 4: add the sub-menu to the Border
            subMenuBorder1.BeginComposite()
              .AddExisting<Menu, Border>(0, 0, subMenu1)
              .EndComposite<Border, BorderArgs>(null);

            //Step 5: create another main level menu item and add the Border to it via wiring On Click event
            return subMenuBorder1;
        }

        private static Border createSubMenu_forMenu2(Canvas cnvs, string cnvsguid2)
        {
            //SUB-MENU 1
            //Step 1: create a Border to hold the sub-menu and set it to hide itself on mouse-out
            Border subMenuBorder = new Border();

            subMenuBorder.Initialize(SUB_MENU_WIDTH, SUB_MENU_HEIGHT, ContainerType.HorizontalPanel, Brushes.Gray, new Thickness(1), Brushes.WhiteSmoke);
            subMenuBorder.BeginSettings<Border>().SetItemBorderSettings<Border>(SUB_MENU_WIDTH, SUB_MENU_HEIGHT, Brushes.LightGray, new Thickness(1)).EndSettings<Border>();
            subMenuBorder.SubscribeEventOnParent<Border, MouseEventArgs>("MouseLeave",
                (eventPattern=>
                {
                    //a: On mouse out, hide sub-menu
                    MenuItemExt.HideSubMenu(cnvs, cnvsguid2);
                }));

            //Step 2: create the submenu and set its orientation to vertical
            Menu subMenu1 = FasterWPF.Factory
           .BeginMenuSettings(SUB_MENU_WIDTH, SUB_MENU_HEIGHT, ContainerType.HorizontalPanel, Brushes.WhiteSmoke)
           //.SetItemBorderSettings<Menu>(173D, 20D, Brushes.Silver, new Thickness(1))
           .EndMenuSettings();
            MenuItemExt.SetMenuOrientationToVertical(subMenu1);

            int toggleIt = 0;

            //Step 3: add the individual menuitems to the submenu
            MenuItem subMenuItem1 = FasterWPF.Factory
             .BeginMenuComposite(SUB_MENU_ITEM_WIDTH, SUB_MENU_ITEM_HEIGHT, "_Change Color on Tab Labels      Alt+E+C", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
             .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
             .AddMenuItem(SUB_MENU_ITEM_BORDER_WIDTH, SUB_MENU_ITEM_BORDER_HEIGHT, (o, ev) =>
             {
                 toggleIt++;

                 switch (toggleIt)
                 {
                     case 1:
                         (Application.Current.Properties["Window"] as CPSWindow).ActOnAllFrameworkElementsByClass("tabLabel", false, fe => { (fe as Control).Background = Brushes.DarkOrange; });
                         break;
                     case 2:
                         (Application.Current.Properties["Window"] as CPSWindow).ActOnAllFrameworkElementsByClass("tabLabel", false, fe => { (fe as Control).Background = Brushes.DarkGreen; });
                         break;
                     case 3:
                         (Application.Current.Properties["Window"] as CPSWindow).ActOnAllFrameworkElementsByClass("tabLabel", false, fe => { (fe as Control).Background = Brushes.DarkKhaki; });
                         break;
                     case 4:
                         (Application.Current.Properties["Window"] as CPSWindow).ActOnAllFrameworkElementsByClass("tabLabel", false, fe => { (fe as Control).Background = Brushes.DarkCyan; });
                         break;
                     case 5:
                         (Application.Current.Properties["Window"] as CPSWindow).ActOnAllFrameworkElementsByClass("tabLabel", false, fe => { (fe as Control).Background = Brushes.DarkTurquoise; });
                         break;
                     default:
                         (Application.Current.Properties["Window"] as CPSWindow).ActOnAllFrameworkElementsByClass("tabLabel", false, fe => { (fe as Control).Background = Brushes.DarkOrchid; });
                         toggleIt = 0;
                         break;
                 }

             })
             .AddImageToMenuItem(@"pack://siteoforigin:,,,/Images/changecolors.png", UriKind.Absolute)
             .EndMenuComposite();


            MenuItem subMenuItem2 = FasterWPF.Factory
             .BeginMenuComposite(SUB_MENU_ITEM_WIDTH, SUB_MENU_ITEM_HEIGHT, "_Remove User Control from 10    Alt+E+R", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
             .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
             .AddMenuItem(SUB_MENU_ITEM_BORDER_WIDTH, SUB_MENU_ITEM_BORDER_HEIGHT, (o, ev) =>
             {

                 //Retrieve Action from Global Store on Application object
                 if (GlobalStoreService.ExistsInGlobalStore(GlobalStoreService.TabControlGuids.Ten, "RegionOneAction1"))
                 {
                     GlobalStoreService.GetFromGlobalStore<Action<object, RoutedEventArgs>>(GlobalStoreService.TabControlGuids.Ten, "RegionOneAction1")(o, (RoutedEventArgs)ev);
                 }
             })
       
             .EndMenuComposite();

            MenuItem subMenuItem3 = FasterWPF.Factory
             .BeginMenuComposite(SUB_MENU_ITEM_WIDTH, SUB_MENU_ITEM_HEIGHT, "_Add User Control to Tab 10", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
             .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
             .AddMenuItem(SUB_MENU_ITEM_BORDER_WIDTH, SUB_MENU_ITEM_BORDER_HEIGHT, (o, ev) =>
             {

                 //Retrieve Action from Global Store on Application object
                 if (GlobalStoreService.ExistsInGlobalStore(GlobalStoreService.TabControlGuids.Ten, "RegionOneAction2"))
                 {
                     GlobalStoreService.GetFromGlobalStore<Action<object, RoutedEventArgs>>(GlobalStoreService.TabControlGuids.Ten, "RegionOneAction2")(o, (RoutedEventArgs)ev);
                 }
             })
             .EndMenuComposite();

            MenuItem subMenuItem4 = FasterWPF.Factory
             .BeginMenuComposite(SUB_MENU_ITEM_WIDTH, SUB_MENU_ITEM_HEIGHT, "_Add WrapPanel User Control", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
             .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
             .AddMenuItem(SUB_MENU_ITEM_BORDER_WIDTH, SUB_MENU_ITEM_BORDER_HEIGHT, (o, ev) =>
             {

                 //Retrieve Action from Global Store on Application object
                 if (GlobalStoreService.ExistsInGlobalStore(GlobalStoreService.TabControlGuids.Two, "TabItem2AddUserControl"))
                 {

                     GlobalStoreService.GetFromGlobalStore<Action<object, RoutedEventArgs>>(GlobalStoreService.TabControlGuids.Two, "TabItem2AddUserControl")(o, (RoutedEventArgs)ev);
                 }
             })
             .EndMenuComposite();

            MenuItem subMenuItem5 = FasterWPF.Factory
             .BeginMenuComposite(SUB_MENU_ITEM_WIDTH, SUB_MENU_ITEM_HEIGHT, "_Add RichText User Control", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
             .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
             .AddMenuItem(SUB_MENU_ITEM_BORDER_WIDTH, SUB_MENU_ITEM_BORDER_HEIGHT, (o, ev) =>
             {

                 //Retrieve Action from Global Store on Application object
                 if (GlobalStoreService.ExistsInGlobalStore(GlobalStoreService.TabControlGuids.Three, "TabItem3AddUserControl"))
                 {
                     GlobalStoreService.GetFromGlobalStore<Action<object, RoutedEventArgs>>(GlobalStoreService.TabControlGuids.Three, "TabItem3AddUserControl")(o, (RoutedEventArgs)ev);
                 }
             })
             .EndMenuComposite();

            MenuItem subMenuItem6 = FasterWPF.Factory
              .BeginMenuComposite(SUB_MENU_ITEM_WIDTH, SUB_MENU_ITEM_HEIGHT, "_aRe-Add Closed WrapPanel", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
              .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
              .AddMenuItem(SUB_MENU_ITEM_BORDER_WIDTH, SUB_MENU_ITEM_BORDER_HEIGHT, (o, ev) =>
              {
                  if (Application.Current.Properties["CreateTabItem2"] != null)
                  {
                      ((Action)Application.Current.Properties["CreateTabItem2"])();
                      ((Action<object, RoutedEventArgs>)Application.Current.Properties["ResizeCorrectly"])(o, ev);
                  }

              })
              .EndMenuComposite();

            MenuItem subMenuItem7 = FasterWPF.Factory
              .BeginMenuComposite(SUB_MENU_ITEM_WIDTH, SUB_MENU_ITEM_HEIGHT, "_bRe-Add Closed RichText", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
              .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
              .AddMenuItem(SUB_MENU_ITEM_BORDER_WIDTH, SUB_MENU_ITEM_BORDER_HEIGHT, (o, ev) =>
              {
                  if (Application.Current.Properties["CreateTabItem3"] != null)
                  {
                      ((Action)Application.Current.Properties["CreateTabItem3"])();
                      ((Action<object, RoutedEventArgs>)Application.Current.Properties["ResizeCorrectly"])(o, ev);
                  }

              })
              .EndMenuComposite();

            MenuItem subMenuItem8 = FasterWPF.Factory
             .BeginMenuComposite(SUB_MENU_ITEM_WIDTH, SUB_MENU_ITEM_HEIGHT, "_Z Change Skin", subMenu1, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
             .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
             .AddMenuItem(SUB_MENU_ITEM_BORDER_WIDTH, SUB_MENU_ITEM_BORDER_HEIGHT, (o, ev) =>
             {
                 //TEST SKINNING BY TYPES
                 BrushExt.ChangeSkin<StackPanel, TextBlock, Border>(App.Current.MainWindow, Brushes.Red, (fe, b) => { ((StackPanel)fe).Background = b; }, Brushes.Red, (fe, b) => { ((TextBlock)fe).Background = b; }, Brushes.Red, (fe, b) => { ((Border)fe).Background = b; });

                 BrushExt.ChangeSkin<ListBox, DataGrid>((Application.Current.Properties["Window"] as CPSWindow), Brushes.Red, (fe, b) =>
                 {
                      ((ListBox)fe).SetVerticalScrollThumbColors<ListBox>("Red", "Silver", "Gray", "Red", "0", "0");
                      ((ListBox)fe).Background = b;
                 }, Brushes.Red, (fe, b) => {
                     ((DataGrid)fe).SetVerticalScrollThumbColors<DataGrid>("Red", "Silver", "Gray", "Red", "0", "0");
                     ((DataGrid)fe).Background = b;
                     ((DataGrid)fe).SetColumnHeaderForeground(Brushes.White);
                     ((DataGrid)fe).SetColumnHeaderColor(Brushes.Red );
                 });

                 BrushExt.ChangeSkin<Label, ComboBox, Menu>(App.Current.MainWindow, Brushes.Red, (fe, b) => { ((Label)fe).Background = b; }, Brushes.Red, (fe, b) => { ((ComboBox)fe).Background = b; }, Brushes.Red, (fe, b) => { ((Menu)fe).Background = b; });

                 BrushExt.ChangeSkinOnContainers<StackPanel>(App.Current.MainWindow, ContainerType.VerticalPanel, Brushes.Red, (fe, b) => { ((StackPanel)fe).Background = b; });

                 BrushExt.ChangeSkinOnContainers<StackPanel>(App.Current.MainWindow, ContainerType.HorizontalPanel, Brushes.Red, (fe, b) => { ((StackPanel)fe).Background = b; });

                 BrushExt.ChangeSkinOnContainers<Grid>(App.Current.MainWindow, ContainerType.Grid, Brushes.Red, (fe, b) => { ((Grid)fe).Background = b; });

                 BrushExt.ChangeSkin<Rectangle, TextBox, TabControl>(App.Current.MainWindow, Brushes.Red, (fe, b) => { ((Rectangle)fe).Fill = b; }, Brushes.Red, (fe, b) => { ((TextBox)fe).Background = b; }, Brushes.Red, (fe, b) =>
                 {
                     ((TabControl)fe).Background = b;
                 });

                 //List<object> listOfHeaderedContent = Selectors.SelectAllHeaderedContent(w, false);

                 BrushExt.ChangeSkinOnHeaderedContent(App.Current.MainWindow, Brushes.Red, (fe, b) =>
                 {

                     if (fe is ContentControl && ((fe as ContentControl).Content is Border))
                     {
                         ((fe as ContentControl).Content as Border).Background = Brushes.Gold;
                     }

                     if (fe is TextBlock)
                     {
                         (fe as TextBlock).Background = Brushes.Gold;
                     }

                     if (fe is Label)
                     {
                         (fe as Label).Background = Brushes.Gold;
                     }
                 });

                 BrushExt.ChangeSkinByClass(App.Current.MainWindow, "decimalControl", Brushes.Purple, (fe, b) => { ((wpfToolkit.DecimalUpDown)fe).Background = b; }, fe => { return true; });
                 
             })
             .EndMenuComposite();

            //Step 4: add the sub-menu to the Border
            subMenuBorder.BeginComposite()
              .AddExisting<Menu, Border>(0, 0, subMenu1)
              .EndComposite<Border, BorderArgs>(null);

            //Step 5: create another main level menu item and add the Border to it via wiring On Click event
            return subMenuBorder;
        }
        
        private static Border createSubMenu_forMenu3(Canvas cnvs, string cnvsguid3)
        {
            //SUB-MENU 2
            //Step 1: create a Border to hold the sub-menu and set it to hide itself on mouse-out
            Border subMenuBorder2 = new Border();
            subMenuBorder2.Initialize(200D, 27D, ContainerType.HorizontalPanel, Brushes.Gray, new Thickness(1), Brushes.WhiteSmoke);
            subMenuBorder2.BeginSettings<Border>().SetItemBorderSettings<Border>(200D, 27D, Brushes.LightGray, new Thickness(1)).EndSettings<Border>();
            subMenuBorder2.SubscribeEventOnParent<Border, MouseEventArgs>("MouseLeave",
                (eventPattern=>
                {
                    //a: On mouse out, hide sub-menu
                    MenuItemExt.HideSubMenu(cnvs, cnvsguid3);
                }));

            //Step 2: create the submenu and set its orientation to vertical
            Menu subMenu2 = FasterWPF.Factory
           .BeginMenuSettings(230D, 27D, ContainerType.HorizontalPanel, Brushes.WhiteSmoke)
           .EndMenuSettings();
            MenuItemExt.SetMenuOrientationToVertical(subMenu2);

            //Step 3: add the individual menuitems to the submenu
            MenuItem subMenu2Item1 = FasterWPF.Factory
             .BeginMenuComposite(225D, 20D, "_Launch Question Box", subMenu2, SUBMENU_MOUSEOVER_BACKGROUND_COLOR, SUBMENU_BACKGROUND_COLOR, Brushes.Black, Brushes.Black, SUBMENU_FONT_FAMILY, SUBMENU_FONT_SIZE, SUBMENU_FONT_WEIGHT, FontStyles.Normal, Brushes.WhiteSmoke)
             .SetMouseOverBorderColor(SUBMENU_MOUSEOVER_BORDER_COLOR, Brushes.Transparent)
             .AddMenuItem(SUB_MENU_ITEM_WIDTH - 91, SUB_MENU_ITEM_HEIGHT - 2, (o, ev) => { 
                 
                 Canvas canVas = (Canvas)Application.Current.Properties["Canvas"];
                 string dialogGuid = Guid.NewGuid().ToString();

                 //DialogHelpers.ShowOKDialog(canVas, dialogGuid, "  Clicked 'View Vacation Photos'.", 200D, 505D, 405D, Brushes.Black, new Thickness(1), Brushes.WhiteSmoke, Brushes.White, Brushes.Gray, Brushes.Black, Brushes.LightGray);    

                 //TitleSettings ts = new TitleSettings() { TitleCaption = "My Question", TitleMargin = new Thickness(1), TitleBackground = Brushes.Navy, TitleForeground = Brushes.White, TitleHeight = 30.0D, TitleFontSettings =new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Normal, FontWeight = FontWeights.Bold }  };
                 //LabelSettings ls = new LabelSettings() { LabelCaption = "How did the chicken get across the road?", LabelMargin = new Thickness(4.0, 0.0, 10.0, 2.0), LabelMinWidth = 297.0D, LabelForeground = Brushes.Black, LabelBackground = Brushes.LightSteelBlue, LabelFontSettings = new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Normal } };
                 
                 //FasterWPF.Dialogs.DialogHelpers.ShowQuestionBoxDialog(canVas, "3c9275d4-42fe-4702-b081-9964de774327", 297.0D, 35.0D, 300.0D, 170.0D, 300.0D, 150.0D,
                 //   Brushes.Black, new Thickness(1), Brushes.LightSteelBlue, ts, ls, "It walked.", new Thickness(4.0, 0.0, 10.0, 4.0), Brushes.Gainsboro, 50, Brushes.AliceBlue, Brushes.Black, Brushes.WhiteSmoke, true,
                 //    Helpers.SetFocus.Delayed, 3, answer => { MessageBox.Show(answer); }, answer => { MessageBox.Show("Cancelled"); }, answer => { MessageBox.Show("Closed"); });




                 TitleSettings ts = new TitleSettings() { TitleCaption = "My Question", TitleMargin = new Thickness(1), TitleBackground = Brushes.Navy, TitleForeground = Brushes.White, TitleHeight = 30.0D, TitleFontSettings = new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Normal, FontWeight = FontWeights.Bold } };
                 LabelSettings ls = new LabelSettings() { LabelCaption = "How did the chicken get across the road?", LabelMargin = new Thickness(4.0, 0.0, 10.0, 2.0), LabelMinWidth = 257.0D, LabelForeground = Brushes.Black, LabelBackground = Brushes.LightSteelBlue, LabelFontSettings = new FontSettings() { FontFamily = "Arial", FontSize = 12.0, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Normal } };
                 
                 ComboBoxSettings cs = new ComboBoxSettings() { ComboItemMinWidth=257D, ComboItemBorderColor = Brushes.Blue, ComboBoxStyle = ComboStyles.TypeAheadButCannotSelectOrCopyText, ComboItemBorderThickness= new Thickness(0D,0D,0D,1D), ComboItemTextRows= Helpers.ItemTextRows.TwoRowsOfText, ScrollViewerWidth=150D, ScrollViewerBackgroundColor="Gainsboro", ScrollViewerPressedColor="Silver", ScrollViewerMouseOverColor="White", HighlightBackgroundColor=Brushes.AliceBlue, HighlightForegroundColor=Brushes.Black, ScrollViewerHeight=150D };
               
                 ListBoxSettings lSettings = new ListBoxSettings() {  HighlightForegroundColor="Navy", ItemHeight = 21, ScrollViewerPressedColor = "LightSteelBlue", HighlightBackgroundColor="SeaShell", ScrollViewerBackgroundColor="Silver",
                     ScrollViewerMouseOverColor="Navy", Height=145.0D, Width=155.0D, ItemBorderThickness = new Thickness(0D, 0D, 0D, 2D), 
                     ItemTextRows = Helpers.ItemTextRows.TwoRowsOfText, 
                     ItemMinWidth = 150D,  ItemBorderColor = Brushes.Black};

                // FasterWPF.Dialogs.DialogHelpers.ShowOKDialog(canVas, "3c9275d4-42fe-4702-b081-9964de774387", "hello", 297.0D, 35.0D, 300.0D, Brushes.Black, new Thickness(1), Brushes.LightSteelBlue, Brushes.Gray, Brushes.White, Brushes.White, Brushes.Blue, true);




                 //FasterWPF.Dialogs.DialogHelpers.ShowComboBoxDialog(canVas, "3c9275d4-42fe-4702-b081-9964de774327", 297.0D, 35.0D, 300.0D, 170.0D, 300.0D, 150.0D,
                 //    Brushes.Black, new Thickness(1), Brushes.LightSteelBlue, cs, ts, ls, "Blue", new Thickness(4.0, 0.0, 10.0, 4.0), Brushes.Gainsboro, Brushes.AliceBlue, Brushes.Black, Brushes.WhiteSmoke, true,
                 //    Helpers.SetFocus.Delayed, 3, comboBx =>
                 //    {

                 //        //comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Blue").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        //comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Red").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        //comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Green").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));

                 //        comboBx.ApplyComboBoxStrategy("20", "White", "Gold", true, "LawnGreen", "Gold", "Gold", "Black", "Orange", "M 1,4.5  L 4.5,1  L 8,4.5", "Blue", "Red", "Gray");

                 //        comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Blue").AddText(1, 0, "Blue as water.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Red").AddText(1, 0, "Red as apple.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Green").AddText(1, 0, "Green as grass.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Orange").AddText(1, 0, "Orange as pumpkin.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Yellow").AddText(1, 0, "Yellow as taxicab.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Purple").AddText(1, 0, "Purple as grape.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Brown").AddText(1, 0, "Brown as dirt.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Black").AddText(1, 0, "Black as midnight.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                 //        //var myBrder = comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Silver").SubscribeDependencyEventOnChild<TextBlock, ComboBox>(0, 0, "IsMouseDirectlyOverChanged", (o3, e) => { MessageBox.Show("yo!"); }, t3 => { return true; }).AddText(1, 0, "Silver as lining.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));


                 //        var myBrder = comboBx.BeginComposite<ComboBox>("hi").AddText(0, 0, "Silver").ModifyAtXY<TextBlock, ComboBox>(0, 0, txtblock => { txtblock.SetSelectorClass("SilverClick"); }).SubscribeMouseSingleClickOnChild<TextBlock, ComboBox>(0, 0, (o3, e) => { MessageBox.Show("fired!"); }).AddText(1, 0, "Silver as lining.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));

                 //        comboBx.SetSelectorClass("SilverClickParent");
                 //        //var myBrder = comboBx.BeginComposite<ComboBox>("hi").AddText(0, 0, "Silver").SubscribeMouseSingleClickOnChild<TextBlock, ComboBox>(0, 0, (o3, e) => { MessageBox.Show("yo!"); }).AddText(1, 0, "Silver as lining.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));

                 //        //var mouseOverObsvble = (IObservable<EventPattern<ValueChangedEventArgs>>)myBrder.GetObservableFromBorder<ValueChangedEventArgs, TextBlock, ComboBox>(0, 0, "IsMouseDirectlyOverChanged");
                 //        //Subject<EventPattern<ValueChangedEventArgs>> eventSubj = (Subject<EventPattern<ValueChangedEventArgs>>)myBrder.GetActionFromBorder<ValueChangedEventArgs, TextBlock, ComboBox>(0, 0, "IsMouseDirectlyOverChanged");
                 //        //eventSubj.OnNext(new EventPattern<ValueChangedEventArgs>(comboBx.GetTextBlock<ComboBox>(myBrder.GetKey().ToString(), 0, 0), new ValueChangedEventArgs(false, true)));

                 //        //var mouseOverObsvble = (IObservable<EventPattern<MouseButtonEventArgs>>)myBrder.GetObservableFromBorder<MouseButtonEventArgs, TextBlock, ComboBox>(0, 0, "PreviewMouseDown");
                 //        //Subject<EventPattern<MouseButtonEventArgs>> eventSubj = (Subject<EventPattern<MouseButtonEventArgs>>)myBrder.GetSubjectFromBorder(0, 0, "PreviewMouseDown");
                 //        //eventSubj.OnNext(new EventPattern<MouseButtonEventArgs>(comboBx.GetTextBlock<ComboBox>(myBrder.GetKey().ToString(), 0, 0), new MouseButtonEventArgs(Mouse.PrimaryDevice, 100, MouseButton.Left)));

                 //        comboBx.FireObservable(myBrder, 0, 0, "PreviewMouseDown", new MouseButtonEventArgs(Mouse.PrimaryDevice, 100, MouseButton.Left));

                 //        comboBx.FireObservable("hi", 0, 0, "PreviewMouseDown", new MouseButtonEventArgs(Mouse.PrimaryDevice, 100, MouseButton.Left));

                 //        Window mainWindow = (Window)Application.Current.Properties["Window"];
                 //        mainWindow.FireSingleClickOnParent<DataGrid>("foo", Helpers.GetMouseClickArgs());

                 //        //IObservable<EventPattern<MouseButtonEventArgs>> mouseOverObsvbleStr = mouseOverObsvble;
                 //        //mouseOverObsvbleStr = comboBx.GetObservableFromParent<MouseButtonEventArgs, ComboBox>("hi", 0, 0, "PreviewMouseDown");


                 //    },
                 //    (Object o1, SelectionChangedEventArgs ev1) =>
                 //    {

                 //        MessageBox.Show("ComboBox Selected Changed: " + (((ComboBox)ev1.Source).SelectedItem).Cast<Border>().GetText<ComboBox>(0, 0).ToString());

                 //    }, answer => { MessageBox.Show(answer); }, answer => { MessageBox.Show("Cancelled"); }, answer => { MessageBox.Show("Closed"); });




                 FasterWPF.Dialogs.DialogHelpers.ShowListBoxDialog(canVas, "3c9275d4-42fe-4702-b081-9964de774327", 297.0D, 44.0D, 135.0D, 300.0D, 320.0D, 300.0D, 150.0D,
                    Brushes.Black, new Thickness(3), Brushes.LightSteelBlue, lSettings, ts, ls, "1", new Thickness(4.0, 0.0, 10.0, 4.0), Brushes.Gainsboro, Brushes.AliceBlue, Brushes.Black, Brushes.WhiteSmoke, true,
                    Helpers.SetFocus.Delayed, 3, listBx =>
                    {

                        //comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Blue").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                        //comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Red").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));
                        //comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Green").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));

                        //comboBx.ApplyComboBoxStrategy("20", "White", "Gold", true, "LawnGreen", "Gold", "Gold", "Black", "Orange", "M 1,4.5  L 4.5,1  L 8,4.5", "Blue", "Red", "Gray");

                        listBx.BeginComposite<ListBox>("1").AddText(0, 0, "Blue").AddText(1, 0, "Blue as water.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
                        listBx.BeginComposite<ListBox>("2").AddText(0, 0, "Red").AddText(1, 0, "Red as apple.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
                        listBx.BeginComposite<ListBox>("3").AddText(0, 0, "Green").AddText(1, 0, "Green as grass.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
                        listBx.BeginComposite<ListBox>("4").AddText(0, 0, "Orange").AddText(1, 0, "Orange as pumpkin.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
                        listBx.BeginComposite<ListBox>("5").AddText(0, 0, "Yellow").AddText(1, 0, "Yellow as taxicab.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
                        listBx.BeginComposite<ListBox>("6").AddText(0, 0, "Purple").AddText(1, 0, "Purple as grape.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
                        listBx.BeginComposite<ListBox>("7").AddText(0, 0, "Brown").AddText(1, 0, "Brown as dirt.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
                        listBx.BeginComposite<ListBox>("8").AddText(0, 0, "Black").AddText(1, 0, "Black as midnight.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());
                        //var myBrder = comboBx.BeginComposite<ComboBox>().AddText(0, 0, "Silver").SubscribeDependencyEventOnChild<TextBlock, ComboBox>(0, 0, "IsMouseDirectlyOverChanged", (o3, e) => { MessageBox.Show("yo!"); }, t3 => { return true; }).AddText(1, 0, "Silver as lining.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));


                        var myBrder = listBx.BeginComposite<ListBox>("hi").AddText(0, 0, "Silver").ModifyAtXY<TextBlock, ListBox>(0, 0, txtblock => { txtblock.SetSelectorClass("SilverClick"); }).SubscribeMouseSingleClickOnChild<TextBlock, ListBox>(0, 0, (o3, e) => { MessageBox.Show("fired!"); }).AddText(1, 0, "Silver as lining.").EndComposite<ListBox, ListBoxArgs>(new ListBoxArgs());

                        listBx.SetSelectorClass("SilverClickParent");
                        //var myBrder = comboBx.BeginComposite<ComboBox>("hi").AddText(0, 0, "Silver").SubscribeMouseSingleClickOnChild<TextBlock, ComboBox>(0, 0, (o3, e) => { MessageBox.Show("yo!"); }).AddText(1, 0, "Silver as lining.").EndComposite<ComboBox, ComboBoxArgs>(new ComboBoxArgs(0, 0));

                        //var mouseOverObsvble = (IObservable<EventPattern<ValueChangedEventArgs>>)myBrder.GetObservableFromBorder<ValueChangedEventArgs, TextBlock, ComboBox>(0, 0, "IsMouseDirectlyOverChanged");
                        //Subject<EventPattern<ValueChangedEventArgs>> eventSubj = (Subject<EventPattern<ValueChangedEventArgs>>)myBrder.GetActionFromBorder<ValueChangedEventArgs, TextBlock, ComboBox>(0, 0, "IsMouseDirectlyOverChanged");
                        //eventSubj.OnNext(new EventPattern<ValueChangedEventArgs>(comboBx.GetTextBlock<ComboBox>(myBrder.GetKey().ToString(), 0, 0), new ValueChangedEventArgs(false, true)));

                        //var mouseOverObsvble = (IObservable<EventPattern<MouseButtonEventArgs>>)myBrder.GetObservableFromBorder<MouseButtonEventArgs, TextBlock, ComboBox>(0, 0, "PreviewMouseDown");
                        //Subject<EventPattern<MouseButtonEventArgs>> eventSubj = (Subject<EventPattern<MouseButtonEventArgs>>)myBrder.GetSubjectFromBorder(0, 0, "PreviewMouseDown");
                        //eventSubj.OnNext(new EventPattern<MouseButtonEventArgs>(comboBx.GetTextBlock<ComboBox>(myBrder.GetKey().ToString(), 0, 0), new MouseButtonEventArgs(Mouse.PrimaryDevice, 100, MouseButton.Left)));

                        listBx.FireObservable(myBrder, 0, 0, "PreviewMouseDown", Helpers.GetMouseClickArgs());

                        listBx.FireObservable("hi", 0, 0, "PreviewMouseDown", Helpers.GetMouseClickArgs());

                        //Window mainWindow = (Window)Application.Current.Properties["Window"];
                        //mainWindow.FireSingleClickOnParent<DataGrid>("foo", Helpers.GetMouseClickArgs());

                        //IObservable<EventPattern<MouseButtonEventArgs>> mouseOverObsvbleStr = mouseOverObsvble;
                        //mouseOverObsvbleStr = comboBx.GetObservableFromParent<MouseButtonEventArgs, ComboBox>("hi", 0, 0, "PreviewMouseDown");


                    },
                    (Object o1, SelectionChangedEventArgs ev1) =>
                    {
                       // MessageBox.Show("ListBox Selected Changed: " + (((ListBox)ev1.Source).SelectedContentControl().GetTextRuns<Grid, ListBox>().FirstOrDefault()));

                    }, answer => { MessageBox.Show(answer); }, answer => { MessageBox.Show("Cancelled"); }, answer => { MessageBox.Show("Closed"); });
        
             
             })
             .EndMenuComposite();




            //Step 4: add the sub-menu to the Border
            subMenuBorder2.BeginComposite()
              .AddExisting<Menu, Border>(0, 0, subMenu2)
              .EndComposite<Border, BorderArgs>(null);

            //Step 5: create another main level menu item and add the Border to it via wiring On Click event
            return subMenuBorder2;
        }

        #endregion

        public static void BuildAeroMenu(Menu mnu, string mnuguid1, string mnuguid3, string mnuguid4, string mnuguid5)
        {
            MenuItem m2 = new MenuItem();
            m2.Header = "_Edit";
            Border handle2 = mnu.BeginComposite<Menu>(mnuguid1).AddExisting<MenuItem, Menu>(0, 0, m2).EndComposite<Menu, MenuArgs>(null);

            MenuItem m3 = FasterWPF.Factory
    .BeginMenuComposite("_View", mnu, mnuguid3, Brushes.Silver, Brushes.WhiteSmoke, Brushes.Black, Brushes.Black, "Verdana", 12, FontWeights.Bold, FontStyles.Normal, Brushes.WhiteSmoke)
    .SetMouseOverBorderColor(Brushes.Gray, Brushes.Gray)
    .AddMenuItem((o, ev) => { MessageBox.Show("Clicked View!"); })
    .EndMenuComposite();
            
            MenuItem subMnu1 = new MenuItem() { Header = "Sub-Menu 1" };
            
            //REMOVE AERO CHROME . . .
            subMnu1.ApplyContextMenuItemStrategy("White", "White", "Blue");


            //TO-DO: NEED TO ADD SUPPORT TO REMOVE AERO CHROME FROM TOP-LEVEL MENU ITEMS SUCH AS M3

            m3.BeginComposite<MenuItem>(mnuguid3)
                .AddExisting<MenuItem, MenuItem>(0, 0, subMnu1)
                .SubscribeEventOnChild<MenuItem, MenuItem, RoutedEventArgs>(0, 0, "Click",
                (
                    (o, ev) =>
                    {
                        MessageBox.Show(o.ToString());
                    }
                )).EndComposite<MenuItem, MenuItemArgs>(null);

            m3.BeginComposite<MenuItem>(mnuguid4)
           .AddExisting<MenuItem, MenuItem>(0, 0, new MenuItem() { Header = "Sub-Menu 2" })
           .SubscribeEventOnChild<MenuItem, MenuItem, RoutedEventArgs>(0, 0, "Click",
           (
               (o, ev) =>
               {
                   MessageBox.Show(o.ToString());
               })
           ).EndComposite<MenuItem, MenuItemArgs>(null);

            m3.BeginComposite<MenuItem>(mnuguid5)
            .AddExisting<MenuItem, MenuItem>(0, 0, new MenuItem() { Header = "Sub-Menu 3" })
            .SubscribeEventOnChild<MenuItem, MenuItem, RoutedEventArgs>(0, 0, "Click",
            (
               (o, ev) =>
               {
                   MessageBox.Show(o.ToString());
                   ((MenuItem)m3).IsSubmenuOpen = false;
               })
            )
            .SubscribeEventOnChild<MenuItem, MenuItem, MouseButtonEventArgs>(0, 0, "MouseLeave",
            (
               (o, ev) => { ((MenuItem)m3).IsSubmenuOpen = false; }))
            .EndComposite<MenuItem, MenuItemArgs>(null);
        }

    }//end of class
} //end of namespace
